<?php
declare(strict_types=1);


namespace App\Mall\Mapper;

use App\Mall\Model\MallTag;
use Hyperf\Database\Model\Builder;
use Mine\Abstracts\AbstractMapper;

/**
 * 标签列表Mapper类
 */
class MallTagMapper extends AbstractMapper
{
    /**
     * @var MallTag
     */
    public $model;

    public function assignModel()
    {
        $this->model = MallTag::class;
    }

    /**
     * 搜索处理器
     * @param Builder $query
     * @param array $params
     * @return Builder
     */
    public function handleSearch(Builder $query, array $params): Builder
    {
        return $query;
    }

    public function select(): array
    {
        return $this->model::query()->get()->map(function ($item) {
            return [
                'id' => $item->id,
                'label' => fastapp_lang_text($item->name),
                'value' => $item->id,
            ];
        })->toArray();
    }
}